package com.AKBAL34.android.Androidmind;



import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Menu extends ListActivity{
	
	String[] lista= {"MainActivity","TextPlay","Email",
			"Camera","ejemplo4","ejemplo5","ejemplo6"};
	
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(Menu.this,android.R.layout.simple_list_item_1, lista));
	}

	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		
		super.onListItemClick(l, v, position, id);
		String cheese = lista[position];
		
		try {
			Class nuevaclase = Class.forName("com.AKBAL34.android.Androidmind."+cheese);
			Intent nuevaintent = new Intent(Menu.this,nuevaclase);
			startActivity(nuevaintent);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}


	
	
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		// TODO Auto-generated method stub
		super.onCreateOptionsMenu(menu);
		MenuInflater salir = getMenuInflater();
		salir.inflate(R.menu.cool_menu, menu);
		
		return true;
	}


	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch(item.getItemId()){
			case R.id.About_Us:
				Intent i = new Intent("android.intent.action.ABOUT");
				startActivity(i);
				
				
				break;
				
			case R.id.Preferences:
				
				Intent p = new Intent("android.intent.action.PREFS");
				startActivity(p);
				
				break;
				
			case R.id.Exit:
				finish();
				break;
			
		}
		return false;
	}

}

